import pandas as pd

from app_config import get_engine_ts

engine = get_engine_ts()

# 构建查询语句
query = f"""
  SELECT * FROM `daily_basic`
  WHERE ts_code IN ({','.join(f"'{code}'" for code in ['002594.SZ'])})
  AND trade_date >= '20240611'
  AND trade_date <= '20240613'
  """

# 执行查询并将结果转换为DataFrame
result_df = pd.read_sql_query(query, engine)

'''circ_mv : 流通市值 * turnover_rate: 换手率  = 成交额'''
result_df['成交额'] = result_df['circ_mv'] * result_df['turnover_rate']

result_df.to_excel("test.xlsx", index=False)

